<?php

/**
 * @package		iTO
 * @subpackage	Components
 * @copyright	Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
 * @author		Kostyantyn Didenko
 * @license		License GNU General Public License version 2 or later
 */

// No direct access to this file
defined('_JEXEC') or die('Restricted access');

// import Joomla view library
jimport('joomla.application.component.view');

/**
 * Listings View
 */
class iTOEstateViewListings extends JView
{
	/**
	 * iTOEstates view display method
	 * @return void
	 */
	function display($tpl = null) 
	{		
		// Get data from the model
		$items	= $this->get('Items');
		$pagination = $this->get('Pagination');
		$state	= $this->get('State');

		// Check for errors.
		if (count($errors = $this->get('Errors'))) 
		{
			JError::raiseError(500, implode('<br />', $errors));
			return false;
		}
		// Assign data to the view
		$this->items = $items;
		$this->pagination = $pagination;
		$this->state = $state;
		
		$this->addToolbar();

		// Display the template
		parent::display($tpl);
	}
	
	/**
	 * Add the page title and toolbar.
	 *
	 * @return  void
	 *
	 * @since   1.6
	 */
	protected function addToolbar()
	{		
		JToolBarHelper::title(JText::_('COM_ITOESTATE_MANAGER_ESTATE'), 'itoestate.png');		
		JToolBarHelper::addNew('listing.add');
		JToolBarHelper::editList('listing.edit');
		JToolBarHelper::divider();
		JToolBarHelper::publish('listing.publish', 'JTOOLBAR_PUBLISH', true);
		JToolBarHelper::unpublish('listing.unpublish', 'JTOOLBAR_UNPUBLISH', true);		
		JToolBarHelper::deleteList('', 'listings.delete');
		JToolBarHelper::divider();
		JToolBarHelper::help('JHELP_COMPONENTS_ITOESTATE_ITOESTATE');
	}
		
}
